package j02menthod;

public class J2sleep {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("enter main");
//        try {
//            Thread.sleep(1000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
//        Thread.sleep(2000);
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
            Thread.sleep(1000);
        }
        System.out.println("end main");
    }
}

class J3lirang{
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("t1-"+i);
                //礼让
                Thread.yield();
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("t222222-"+i);
            }
        });
        t1.start();
        t2.start();
    }
}
